<html>
<body>BIL is a basic imperative language with support for some basic features 
like numeric constants, arithmetic expressions, conditions, global and local 
variable scoping, assignment, selection and iteration.  This is the Compiler 
Construction project for Vic Fryzel &lt;<a href="mailto:vef3240@rit.edu">
vef3240@rit.edu</a>&gt;, for Winter 2008-2009 at RIT.

<h1>Introduction</h1>
<p>
BIL is a basic imperative language with support for the following features:
<ul>
	<li>Integer, string, and boolean operations
		<ul>
			<li>
				Sum, difference, product, division, modulo, greater than,
				greater than or equal, lesser than, lesser than or equal
			</li>
			<li>Equivalence, inequivalence</li>
			<li>AND and OR boolean operations</li>
		</ul>
	</li>
	<li>String printing</li>
	<li>Direct assignation without declaration</li>
	<li>Conditional and loop statements</li>
	<li>Comments</li>
	<li>General white space irrelevance except directly between nodes</li>
	<li><del>List types</del></li>
	<li><del>Functions</del></li>
</ul>
</p>

<h1>Installation</h1>
<p>
JARs and documentation for all milestones can be found 
<a href="http://shellsage.com/projects/compiler/">here</a>.
</p>

<h1>Usage</h1>
<h3>Milestone 1: Parser</h3>
<p>
	<pre>
java -jar Parser_Fryzel.jar
[Enter your input]
[Hit Ctrl+d to show parse tree]
	</pre>
</p>
<h3>Milestone 2: Interpreter</h3>
<p>
	<pre>
java -jar Interpreter_Fryzel.jar
[Enter your input]
[Hit Ctrl+d to execute]
	</pre>
	<pre>
java -jar Interpreter_Fryzel.jar your-source-file.bil
	</pre>
</p>
<h3>Milestone 3: Compiler</h3>
<p>
	<pre>
java -jar Compiler_Fryzel.jar > your-vm-source-file.js
[Enter your input]
[Hit Ctrl+d to execute]
	</pre>
		<pre>
java -jar Compiler_Fryzel.jar your-source-file > your-vm-source-file.js
	</pre>
</p>

<h1>Documentation</h1>
<p>Documenation references include:
<ul>
	<li><a href="doc-files/langref.html">BIL Language Reference</a></li>
</ul>

<h1>Examples</h1>
<table border="1" cellpadding="2" cellspacing="2">
	<tr><th>Name</th><th>Code</th></tr>
	<tr>
		<td>Fibonacci number</td>
		<td>
			<pre>
# Computes and prints the 1000th Fibonacci number
n = 2
first = 0
second = 1
while(n < 1000):
  current = first + second
  first = second
  second = current
end
print current
			</pre>
		</td>
	</tr>
	<tr>
		<td>Evens & odds</td>
		<td>
			<pre>
# Prints whether a list of numbers is even or odd
current = 0
while(current < 10):
  if(current % 2 == 0):
    print "even\n"
  else:
    print "odd\n"
  end
end
current = current + 1
			</pre>
		</td>
	</tr>
</table>

<h1>Examples of Every Current Language Feature</h1>
<p>
<ul>
	<li>
		<pre>
# Assignation
a = 3
b = "Hello World"
		</pre>
	</li>
	<li>
		<pre>
# Integer Operations
a = 3
b = 4
a = a + a
a = a - 2 * 3
a = b / 7 % 2
		</pre>
	</li>
	<li>
		<pre>
# Printing
a = 3
b = "Hello World"
print a
print b
print "Hello Rochester"
		</pre>
	</li>
	<li>
		<pre>
# Conditions and selection
a = 4
b = 3
if(a >= b):
  b = b + 1
end

if(b > a):
  a = b
end

if(b == a || b < a):
  c = 1
  if(c < a):
    a = a - 1
    if(c < b):
      b = 2
    end
  end
else:
  b = 3
  if(a != b && a > 5):
    b = 6
  else:
    c = 7
  end
end
		</pre>
	</li>
	<li>
		<pre>
# Global and local variables
# The following creates and modifies a and b in the global scope ONLY
a = 1
if(a == 1):
  b = 2
  a = 3
end
print b			# prints 2
print a			# prints 3

a = 1
b = 2
if(a == 1):
  begin:
    a = 3
    b = 4
    c = 5		# available to this scope and children
    begin:
      print c	# prints 5
      c = 6		# modifies c from 3 lines prior
      d = 6		# local only
    end
    print c		# prints 6
  end
end
print a			# prints 3
print b			# prints 4
print c			# prints 0, default for undefined
print d			# prints 0, default for undefined
		</pre>
	</li>
	<li>
		<pre>
# Iteration
a = 3
b = 6
while a > 0:
  print a
  a = a - 1
  while b < 10:
    if(a <= 1):
      print b
      b = b + 2
    end
  end
end
		</pre>
	</li>
</ul>
</p>
</body>
</html>
